#include<bits/stdc++.h>
using namespace std;
class Solution {
public:
    bool isprime(int n) {
        if (n < 2)
            return false;
        for (int i = 2; i <= (int)sqrt(n); i++) {
            if (n % i == 0)
                return false;
        }
        return true;
    }

    int diagonalPrime(vector<vector<int>>& nums) {
        int n = nums.size();
        int sum = 0;
        int m = nums[0].size();
        for (int i = 0; i < n; i++) {
            if (isprime(nums[i][i]))
                sum = max(sum, nums[i][i]);
            if (isprime(nums[i][m - i - 1]))
                sum = max(sum, nums[i][m - i - 1]);
        }

        return sum;
    }
};
int main(){
  Solution s;
  vector<vector<int>> nums = {
    {1,2,3},
    {7,8,9},
    {12,13,14},
  };

  cout << s.diagonalPrime(nums);

  return 0;
  }//
// Created by LENOVO on 2025/8/5.
//
